# SA2410.ZCE

from pandas import DataFrame

from app_config import get_pro

pro = get_pro()

if __name__ == '__main__':
    import pandas as pd

    # 读取文件，指定分隔符为空格（\s+ 匹配一个或多个空格）
    df = pd.read_csv('example.txt', sep='\s+', header=None, names=['col1', 'col2', 'col3', 'value'])

    # 按 col1 分组
    grouped = df.groupby('col1')

    data_concat = {
        'col1': [],
        'col2': [],
        'col3': [],
        'value': [],
        'pct_change': []
    }
    df_concat = pd.DataFrame(data_concat)

    # 遍历每个分组并打印
    for group_name, group_df in grouped:
        group_df['pct_change'] = group_df['value'].pct_change()
        df_concat = pd.concat([df_concat, group_df], ignore_index=True)

    print(df_concat)
    df_concat['abs_change'] = df_concat['pct_change'].abs()
    values = df_concat.sort_values(by='abs_change', ascending=False)
    print(values.head(20))
